<?php

namespace app\api\validate;

use think\Validate;

class CartValidate extends Validate
{
    protected $rule = [
        'goods_id' => 'require|integer',
        'buy_num' => 'require|integer',
        'store_id' => 'require|integer',
        'type' => 'require|integer',
        'cart_id' => 'require'
    ];

    protected $message = [
        'goods_id.require' => '商品不能为空!',
        'goods_id.integer' => '非法参数!',
        'buy_num.require' => '数量不能为空!',
        'buy_num.integer' => '非法参数!',
        'store_id.require' => '非法请求!',
        'store_id.integer' => '非法参数!',
        'cart_id.require' => '未找到指定商品',
        // 'cart_id.integer' => '参数异常',
        'type.require' => '类型有误',
        'type.integer' => '类型有误'
    ];

    protected $scene = [
        'add'  =>  ['goods_id','buy_num', 'store_id'],
        'modify' => ['cart_id', 'type', 'store_id'],
        'del' => ['cart_id', 'store_id']
    ]; 
}